<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ page import="com.hzqy.commons.utils.ConstantUtils" %>
<%@ taglib prefix="limits" uri="/WEB-INF/tld/limits.tld"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>组织列表</title>
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/defalut.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/public.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/ddspstyle.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/icon.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/WdatePicker/skin/WdatePicker.css">
<script type="text/javascript" src="../../static/js/jquery.min.js"></script>
<script type="text/javascript" src="../../static/js/jquery.easyui.min.js"></script>
<script type="text/javascript"	src="../../static/js/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../static/js/jquery.validate.js"></script>
<script type="text/javascript" src="../../static/js/index.js"></script>
<script type="text/javascript" src="../../static/js/WdatePicker/WdatePicker.js"></script>
<script type="text/javascript" charset="utf-8" src="../../ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="../../ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../../ueditor/lang/zh-cn/zh-cn.js"></script>
<%
String []nonceObj=ConstantUtils.getNonceObject();
%>


<script type="text/javascript">
		var selectIndex = "-1";	
		var queryParams;
		function EasyuiDatagrid() {
			$("#easyui-datagrid").datagrid({
				//url: '../../virtual_channel/pmsOrg_list.do',
				url: '../../pms/industry_orgVo_list.do',
				nowrap: true,
				striped: true,
				border: false,
				fit: true,
				rownumbers:true,
				queryParams: getGueryParams(),
				columns: [[
					{field:'id',checkbox:true},
					{field:'f_po_id',title:'ID',align:'center',width:50},
					{field:'f_po_name',title:'组织名称',align:'center',width:250},
					{field:'f_po_code',title:'组织编号',align:'center',width:100},	
					{field:'f_po_desc',title:'组织描述',align:'center',width:60},
					{field:'f_po_address',title:'地址',align:'center',width:60},
					{field:'f_po_email',title:'email',align:'center',width:140},
				]],
				singleSelect:false,
				pagination:true,
				pageList:[10,20,30,40,50],
				pageSize:10,
				toolbar: '#toolbar',
				
				onExpandRow: function(index,row){
				
				},
				onUnselect: function(rowIndex,rowData) {
					
				},
				onSelect: function(index,rowData) {
					
				},
				
				onCheckAll: function(rowIndex,rowData) {
					
				},
				onUncheckAll: function(rowIndex,rowData) {
				
				},
				
				onLoadSuccess: function(data) {
					if(data.total==-1) {
						$.messager.defaults={ok:"确定",cancel:"取消"};
						$.messager.confirm('提示', '用户尚未登录,请登录', function(r){
						if (r){
						    window.parent.location.href='/login.do';
						    return false;
						}});
					}else{               //此段注释可以控制单选，备用
						$("input[name=id]").click(function () {
		                    var ischecked = $(this).is(":checked");
		                   // $("input:checkbox[name=id]:checked").attr("checked", false);
		                    $('#easyui-datagrid').datagrid('clearSelections');
		                    $('#easyui-datagrid').datagrid("unselectAll");
		                    if (ischecked) {
		                        $(this).attr("checked", true);
		                    } else {
		                        $(this).attr("checked", false);
		                    }
		                });
					}
				},
			    onClickRow: function (rowIndex, rowData) {
		            $('#easyui-datagrid').datagrid("unselectAll");//取消选中当前所有行
		            $('#easyui-datagrid').datagrid("selectRow", rowIndex);//选中当前点击的行
		            if (rowIndex == selectIndex) {
		            	$('#easyui-datagrid').datagrid("unselectAll");//取消选中当前所有行
		            	selectIndex="-1";
		            }else{
		            	selectIndex=rowIndex;
		            }
		        } 
			});
		}
	
		function getGueryParams(){
			return {
				f_po_name:$("#f_po_name").val(),
				f_po_code:$("#f_po_code").val(),
			};
		}
		
		$(function(){
			/* if(id_==0){
				$.messager.alert('提示', "未获得内容id!!!", 'info', function() {
					$.messager.progress('close');
				});
				return;	
			} */
			new EasyuiDatagrid();
			gotoSearch = function(){
				$("#easyui-datagrid").datagrid('reload',getGueryParams());
			};
			
			onClickBtnDelete = function(id){
				$.messager.confirm('确定删除演职人员','确定删除演职人员么?',function(r){
					if(r){
						app_ajax('delete_cast.do?f_cast_id='+id+'&stime=<%=nonceObj[0]%>&sign=<%=nonceObj[1]%>',
						'',
						function(msg){
							if(msg.success) {
								alert("删除成功!");
								if (checkAjaxRequestValidity(msg)) {
									gotoSearch($('#easyui-treegrid'));
								}
							} else {
								alert("删除异常，请联系管理员");
								if($.isFunction(window.showMessager)){
									window.showMessager(msg.resultTitle,msg.result);
								}
							}
							window.location.reload();
						}
						);
					}
				});
			};
		});
		
		function SubgridTabOnSelect(title,index){
			setTimeout(function(){
				$("#easyui-datagrid").datagrid('fixDetailRowHeight',index);
			},300);
			setTimeout(function(){
				$("#easyui-datagrid").datagrid('fixDetailRowHeight',index);
			},3000);
	    }
		
		function load(){
			$(".datagrid-row-expander datagrid-row-expand").attr("display","none"); 
		}
		
		
		function onpress(){
			var event=arguments.callee.caller.arguments[0]||window.event;//消除浏览器差异
	   		  	if (event.keyCode == 13){  
	      			gotoSearch($('#easyui-treegrid'));
	    		}
		}
		function updateadvertisementname(){
			var selections = $("#easyui-datagrid").datagrid('getSelections');
			if(selections==null || selections.length == 0){
				//return;
				alert("未选择模板!");
			}else if(selections.length > 1 ){
				var start="";
				var end="";
				var preEnd="";
				for(var i=0;i<selections.length;i++) {
					start = selections[i].f_am_showtime;
					end = selections[i].f_am_closetime;
					//console.log(start);
					if(i>0){
						if(start<preEnd){
							$.messager.alert('提示', "不能在同一时间段显示多个前插模板!", 'info', function() {
								$.messager.progress('close');
							});
							return;
						}
					}
					preEnd=end;
				}
			}
			var ids="", idList="";
			for(var i=0;i<selections.length;i++) {
				var id = selections[i].f_po_name;
				ids+=id+",";
				idList+=selections[i].f_po_id+",";
			}
			if(ids!=""){
				ids = ids.substring(0, ids.lastIndexOf(','));  
			}
			if(idList!=""){
				idList = idList.substring(0, idList.lastIndexOf(','));  
			}
			if(idList == ""){
				idList="0";
			}
			window.parent.document.getElementById("f_vc_customid").value=idList;
			window.parent.document.getElementById("f_vc_customName").value=ids;
	        parent.$('#openselect').dialog('close');
	        parent.init();
		}
	</script>
</head>
<body onload="load();" style="width: 100%;">
	<input type="hidden" id="sessionId" value="${pageContext.session.id}" />
	<table id="easyui-datagrid" title="组织列表"></table>
	<div id="toolbar" class="easyui_datagrid_toolbar" style="">
		<div class="easyuiSearch">
			<form onsubmit="return false;" method="post">
				<table cellspacing="0" cellpadding="0" width="90%">
					<tr>
						<td align="left" width="10%">组织名称：</td>&nbsp;
						<td align="left" width="15%"><input name="f_po_name" id="f_po_name" style="width: 150px;" onkeydown="onpress();" /></td>
					</tr>
					<tr>
						<td align="left" width="10%">组织编号：</td>
						<td align="left" width="10%">
							<input name="f_po_code" id="f_po_code" style="width: 150px;" onkeydown="onpress();" />
						</td>
						
						<td align="left" width="15%">
							<limits:uiAuth url="content_list.do">
								<a href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-search', plain:true"
									onclick="gotoSearch($('#easyui-datagrid'))">查询</a>
							</limits:uiAuth>
						</td>
						<td align="left" width="25%">
							<a id="easyui-linkbutton" class="easyui-linkbutton"
							data-options="iconCls:'icon-ok'" href="javascript:void(0);"
							onclick="updateadvertisementname()">确认</a>
						</td>
					</tr>
				</table>
			</form>
		</div>
		<div style="margin-bottom: 5px">
		</div>
	</div>
	<div id="dlg" class="easyui-dialog"
		style="width: 950px; height: 600px; padding-top: 0px;"
		data-options="title:'内容管理', iconCls:'icon-save',modal:true,closed:true,buttons:'#dlg_buttons'">
		<iframe scrolling="auto" frameborder="0"
			style="width: 100%; height: 99%;"></iframe>
	</div>
	
	
	

<script type="text/javascript">
</script>
	
	
	
</body>
</html>